package com.xindaoapp.happypet.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xindaoapp.happypet.R;
import com.xindaoapp.happypet.application.HappyPetApplication;
import com.xindaoapp.happypet.bean.NiuniuRecord;
import com.xindaoapp.happypet.utils.CommonUtil;
import com.xindaoapp.happypet.utils.IRequest;

/**
 * 尾巴明细
 * 
 * @author xindaoapp
 * 
 */
public class WeibaDetailAdapter extends XinDaoBaseAdapter<NiuniuRecord> {



    public WeibaDetailAdapter(Context context, List<NiuniuRecord> iniData, int pageSize, int res,
            int loadingRes) {
        super(context, iniData, pageSize, res, loadingRes);
        // TODO Auto-generated constructor stub
    }



    @Override
    public void nextPage(int start, int size,
            final ILoadNextPageData<NiuniuRecord> iLoadNextPageData) {
        // TODO Auto-generated method stub
        super.nextPage(start, size, iLoadNextPageData);
        HappyPetApplication.get().getMoccaApi()
                .getNiuniuRecord(start, size, new IRequest<List<NiuniuRecord>>() {

                    @Override
                    public void request(List<NiuniuRecord> t) {
                        // iLoadNextPageData.loadNextPageData(t);
                        iLoadNextPageData.loadNextPageData(t == null ? null : t);
                    }
                });
    }



    @Override
    public View getView(int position, View convertView, ViewGroup parent, NiuniuRecord niuniu) {
        // TODO Auto-generated method stub
        ViewHolder holder = (ViewHolder) convertView.getTag();

        if (holder == null) {
            holder = new ViewHolder();
            holder.tv_date = (TextView) convertView.findViewById(R.id.tv_date);
            holder.tv_opt = (TextView) convertView.findViewById(R.id.tv_opt);
            holder.tv_niuniubi = (TextView) convertView.findViewById(R.id.tv_niuniubi);
            convertView.setTag(holder);
        }


        holder.tv_date.setText(CommonUtil.formatTimeForQiandao(niuniu.addtime));
        holder.tv_opt.setText(niuniu.type);
        holder.tv_niuniubi.setText(niuniu.extcredits2);

        return convertView;
    }



    class ViewHolder {
        private TextView tv_date, tv_opt, tv_niuniubi;

    }

}
